﻿Public Class ProjectForm
    Private company As Company = New Company()
    Private timerObservers = New List(Of TimeObserver)


    Private Sub Form1_Load() Handles MyBase.Load
        createCompanyProcessPanel()
        createActorsPanel()
        createProjectManagerPanel()
        initTimer()
        initTimerObservers()
    End Sub

    Private Sub initTimer()
        Timer.Interval = 500
        Timer.Enabled = True
    End Sub

    Private Sub createActorsPanel()
        Dim actorsPanel = New ActorsPanel()
        Controls.Add(actorsPanel)
        actorsPanel.addActor(company.getBusinessAnalist())
        actorsPanel.addActor(company.getDeveloper())
        actorsPanel.addActor(company.getTester())
        actorsPanel.setActorsInPanel()
        actorsPanel.Location = New Point(37, 100)
    End Sub

    Private Sub createProjectManagerPanel()
        Dim pmStatusObs As LabelStatusObserver = New LabelStatusObserver(PmStatusLabel, company.getProjectManager())
    End Sub

    Private Sub createCompanyProcessPanel()
        Dim companyPanel = New CompanyPanel(company)
        companyPanel.Location = New Point(458, 100)
        Controls.Add(companyPanel)
    End Sub

    Private Sub initTimerObservers()
        timerObservers.Add(company.getBusinessAnalist())
        timerObservers.Add(company.getDeveloper())
        timerObservers.Add(company.getTester())
        timerObservers.Add(company.getProjectManager())
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
        For Each timerObserver In timerObservers
            timerObserver.timeNotification()
        Next
    End Sub

    Private Sub StartProcessButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartProcessButton.Click
        company.reset()
        company.startProcess()
    End Sub

    Private Sub ResetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetButton.Click
        company.reset()
        Randomize()
    End Sub
End Class
